<?php
class Modules {
	var $id = null;
	var $title = null;
	var $visible = 0;
	var $link = null;
	
	function viewAll() {
		$query = "select * from dt_modules";
		$data = mysql_query($query);
		return $data;
	}
	
	function selectSingle($id) {
		$query = "select * from dt_modules where m_id = '$id'";
		$data = mysql_query($query);
		return $data;
	}
	
	function update($id, $title, $visible) {
		$query = "update dt_modules set m_title = '$title', m_visible = '$visible', where m_id = '$id'";
		mysql_query($query);
	}
	
	function insert($title, $visible, $type) {
            $query = "insert into dt_modules (`m_title`, `m_visible`, `type`) values ('$title', '$visible', '$type')";
            mysql_query($query);
	}
	
	function delete($id) {
		$query = "delete from dt_modules where m_id = '$id'";
		mysql_query($query);
	}
	
	/*
	 * modules for pages
	 */
	function mfpSelectSingle($id) {
		$query = "select * from dt_mod_visible where id = '$id'";
		$data = mysql_query($query);
		return $data;
	}
	
	function mfpViewAll() {
		$query = "select * from dt_mod_visieble";
		$data = mysql_query($query);
		return $data;
	}
	
	function mfpSelectByModID($m_id) {
		$query = "select * from dt_mod_visible where m_id = '$m_id'";
		$data = mysql_query($query);
		return $data;
	}
	
	function mfpSelectByModID_Pg($m_id) {
		$query = "select * from dt_mod_visible where m_id = '$m_id' and p_id != '0'";
		$data = mysql_query($query);
		return $data;
	}
	
	function mfpSelectByModID_Ctg($m_id) {
		$query = "select * from dt_mod_visible where m_id = '$m_id' and c_id != '0'";
		$data = mysql_query($query);
		return $data;
	}
	
	function mfpSelectByModID_Off($m_id) {
		$query = "select * from dt_mod_visible where m_id = '$m_id' and o_id != '0'";
		$data = mysql_query($query);
		return $data;
	}
	
	function mfpSelectByModID_News($m_id){
		$query = "select * from dt_mod_visible where m_id = '$m_id' and n_id != '0'";
		$data = mysql_query($query);
		return $data;
	}
	
	function mfpSelectByModID_Top($m_id){
		$query = "select * from dt_mod_visible where m_id = '$m_id' and t_id != '0'";
		$data = mysql_query($query);
		return $data;
	}
	
	function mfpUpdate($id, $z_id, $order, $visible) {
		$query="update dt_mod_visible set `z_id` = '$z_id', `order` = '$order', `visible` = '$visible' where id = '$id'";
		mysql_query($query);
	}
	
	function mfpInsert($m_id, $p_id, $c_id, $o_id, $z_id, $n_id, $t_id, $order, $visible, $type) {
		$query = "insert into dt_mod_visible (`m_id`, `p_id`, `c_id`, `o_id`, `z_id`, `n_id`, `t_id`, `order`, `visible`, `type`) values ('$m_id', '$p_id', '$c_id', '$o_id', '$z_id', '$n_id', '$t_id', '$order', '$visible', '$type')";
		mysql_query($query);
	}
	
	function mfpDelete($id) {
		$query = "delete from dt_mod_visible where id = '$id'";
		mysql_query($query);
	}
}
?>